package com.example.smartcity_poverty.ui.AllService.SeekHouse.adapter

import android.content.Intent
import android.os.Bundle
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.R
import com.example.smartcity_poverty.logic.ServiceBean.SeekHouseBean.SHHotListAllModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.ui.AllService.SeekHouse.activity.SHShowDataActivity
import kotlinx.android.synthetic.main.re_sh_home_hot_list.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *
 **/
class SHHotListAdapter(
    val list: MutableList<SHHotListAllModel.RowsBean>,
    layoutId: Int
) : BaseRecyclerAdapter<SHHotListAllModel.RowsBean>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: SHHotListAllModel.RowsBean,
        position: Int,
        holder: BaseViewHolder
    ) {
        val d = list[position]
        val fv = holder.viewFind
        val con = holder.viewFind.view?.context

        glide(url + d.pic, fv.shHomeHotListImage)
        fv.shHomeHotListName.text = d.sourceName
        fv.shHomeHotListSize.text = "房源面积: ${d.areaSize}㎡"
        fv.shHomeHotListMoney.text = "价格: ${d.price}"

        holder.itemView.setOnClickListener {
            con?.startActivity(Intent(con, SHShowDataActivity::class.java).apply {
                putExtra("id", d.id.toString())
                putExtra("personRows", list[position])
            })
        }
    }
}